package com.zyl;

import com.zyl.bean.Environment;
import com.zyl.client.Client;
import com.zyl.factory.FactoryInstance;
import com.zyl.gather.Gather;
import com.zyl.log.Log;
import com.zyl.log.LogImpl;

import java.util.List;

/**
 * @version v1.0
 * @ProjectName: env_gather
 * @Package: com.zyl
 * @ClassName: Main
 * @Description TODO()
 * @Author 翟玉龙
 * @Date 2024/10/18-14:35
 */
public class ClientMain {
    public static void main(String[] args) {
        // 创建采集模块对象 采集数据
        Gather gather = FactoryInstance.init().getInstance("gather", Gather.class);
        // 日志模块的实现类对象
        Log log = LogImpl.getInstance();
        try {
            // 采集数据
            List<Environment> list = gather.gather();
            if(list.isEmpty()) {
                // 如果采集的数据为空 那么没有传输的必要
                log.warn("本次采集的数据条数为0");
                return;
            }
            // 通过客户端网络模块进行传输
            Client client = FactoryInstance.init().getInstance("client", Client.class);
            client.send(list);
        } catch (Exception e) {
            log.error("出现异常，异常的原因：" + e);
        }
    }
}
